﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using QzEbook.BaseView;
using QzEbook.View;
using QzEbook.AccessObject;

public partial class detailView : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindSitemap();
            BindData();
        }
    }

    private void BindSitemap()
    {
        WebMaster master = this.Master as WebMaster;
        QzSiteMapNode node = new QzSiteMapNode("list.xhtml", "电子书列表", "所有电子书");
        master.sitemap.addChild(node);

        string name;
        string path;


        if (Request.Url.Query != string.Empty)
        {
            if (!String.IsNullOrEmpty(Request["Cid"]))
            {
                path = String.Format("list.xhtml?Cid={0}", Request["Cid"]);
                name = Category.getName(int.Parse(Request["Cid"]));
                node = new QzSiteMapNode(path, name, name);
                master.sitemap.addChild(node);
            }
            else if (!String.IsNullOrEmpty(Request["Tid"]))
            {
                path = String.Format("tag.xhtml?Tid={0}", Request["Tid"]);
                name = Tag.getName(int.Parse(Request["Tid"]));
                node = new QzSiteMapNode(path, name, name);
                master.sitemap.addChild(node);
            }
            else if (!string.IsNullOrEmpty(Request["Uid"]))
            {
                path = String.Format("user.xhtml?Uid={0}", Request["Uid"]);
                name = "用户";
                node = new QzSiteMapNode(path, name, name);
                master.sitemap.addChild(node);
            }
            else if (!String.IsNullOrEmpty(Request["Type"]))
            {
                switch (Request["Type"])
                {
                    case "N":
                        name = "最新";
                        break;
                    case "W":
                        name = "本周";
                        break;
                    case "M":
                        name = "本月";
                        break;
                    case "B":
                        name = "购书";
                        break;
                    case "P":
                        name = "评论最多";
                        break;
                    case "K":
                        name = "点击最多";
                        break;
                    default:
                        name = "所有";
                        break;
                }
                path = String.Format("list.xhtml?Type={0}", Request["Type"]);
                node = new QzSiteMapNode(path, name, name);
                master.sitemap.addChild(node);
            }

            node = new QzSiteMapNode(Request.Url.PathAndQuery,"展示","展示");
            master.sitemap.addChild(node);
        }
    }

    private void BindData()
    {
        string urlId = Request["BID"] as string;
        if (urlId == null)
        {
            Response.StatusCode = 404;
            Response.Write("不能没有参数");
            Response.End();
        }

    }
}
